<template>
	<view>
		adddddddddddddd
	</view>
</template>

<script>
	import {cacheSize, cleanCache} from 'jy-request'
	import {
		isOpen,
		openDb,
		addTab,
		mergeSql,
		getDataList,
		addTabItem,
		closeSQL,
		deleteInformationType,
		getTable,
		getCount,
		updateSQL,
		isTable,
		selectDataList
	} from '@/js_sdk/lyz-sqlite/index.js'
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
			var that = this;
			that.viewdata();
		},
		methods: {
			viewdata(){
				var that = this;
				//密码测试
				let strs = this.newtools.fun2();
				console.log(this.newtools.fun1(strs));
				let jsonstr = this.newtools.fun1(strs);
				//加密测试
				//加密值
				let jiamistr = this.AES.encrypt(strs,'1jhtconstrj2age3','_tongyongjiakao_')
				console.log(jiamistr);
				
				var sql = `select * from Tiku `
				plus.sqlite.selectSql({
					name: 'data',
					sql: sql,
					success(e) {
						console.log(e);
						//console.log(e.length)
						//console.log(e[0].option1)
						//let j = that.AES.encrypt(e[0].option1,'1jhtconstrj2age3','_tongyongjiakao_');
						
						//console.log(j);
						that.jiami(e[0])
						//console.log(e);
					},
					fail(e) {
						console.log(e)
						
					}
				})
			},
			jiami(jsonstr){
				//新表中添加
				// 如何添加    1.循环加到新表  2.批量加入新表
				console.log(jsonstr)
				//ALTER TABLE 'IPC_FGUID' ADD 'iPassageway' VARCHAR(100) DEFAULT 0;
				//设置加密参数
				let option1 = jsonstr.option1;
				let option1_j = this.AES.encrypt(option1,'1jhtconstrj2age3','_tongyongjiakao_')
				let option2 = jsonstr.option2;
				let option2_j = this.AES.encrypt(option2,'1jhtconstrj2age3','_tongyongjiakao_')
				let option3 = jsonstr.option3;
				let option3_j = this.AES.encrypt(option3,'1jhtconstrj2age3','_tongyongjiakao_')
				let option4 = jsonstr.option4;
				let option4_j = this.AES.encrypt(option4,'1jhtconstrj2age3','_tongyongjiakao_')
				
				let question = jsonstr.question;
				let question_j = this.AES.encrypt(question,'1jhtconstrj2age3','_tongyongjiakao_')
				let tdesc = jsonstr.tdesc;
				let tdesc_j = this.AES.encrypt(tdesc,'1jhtconstrj2age3','_tongyongjiakao_')
				
				//写入到新的数据库中
				let newjson = jsonstr;
				
				newjson.option1 = option1_j;
				newjson.option2 = option2_j;
				newjson.option3 = option3_j;
				newjson.option4 = option4_j;
				
				newjson.question = question_j;
				newjson.tdesc = tdesc_j;
				newjson.collect = 0;		//收藏
				newjson.wrong = 0;		//易错题
				newjson.isadd = "1";
				
				console.log(newjson)
				//添加到新表中
				//json中删除tid
				let tids = newjson.tid;
				delete newjson.tid;
				console.log(newjson);
				
				//修改原来的数据   标识已添加过
				updateSQL('data', 'Tiku', newjson, 'tid', tids).then(res => {
					console.log('1111')
					console.log(res)
					uni.reLaunch({
						url:'./demo'
					})
					setTimeout(function(){
						uni.navigateTo({
							url:'./demo'
						})
					},200)
				})
				
				
				console.log("option1_j",option1_j);
				//
				// let j = this.AES.encrypt(str,'1jhtconstrj2age3','_tongyongjiakao_')
					
				// console.log(j);
					
				
			}
		}
	}
</script>

<style>

</style>
